use anyhow::Result;
use notify_server::{AppConfig, get_router};
use tokio::net::TcpListener;
use tracing::{info, level_filters::LevelFilter};
use tracing_subscriber::{Layer, fmt::Layer};



#[tokio::main]
async fn main() ->Result<()> {
    let layer = Layer::new().with_filter(LevelFilter::INFO);
    tracing_subscriber::registry().with(layer).init();

    let addr = "0.0.0.0:6687";

    let config = AppConfig::load().expect("Failed to load config");

    let app = get_router(config.auth)?;
    let listener = TcpListener::bind(&addr).await?;
    info!("Notify server listening on {}", addr);
    axum::serve(listener, app).await?;
    Ok(())
}